package com.atguigu.jxc.controller;


import com.atguigu.jxc.domain.ServiceVO;

import com.atguigu.jxc.entity.Supplier;
import com.atguigu.jxc.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * ClassName: SupplierController
 * Package: com.atguigu.jxc.controller
 * Description:
 *
 * @Author 梅超凡
 * @Create 2025/2/21 14:05
 * @Version 1.0
 */
@RestController
@RequestMapping("/supplier")
public class SupplierController {

    @Autowired
    private SupplierService supplierService;

    /**
     * 分页查询供应商信息
     * @param page 页码
     * @param rows 行数
     * @param supplierName 供应商名称
     * @return Map<String, Object>
     */
    @PostMapping("/list")
    public Map<String, Object> list(Integer page, Integer rows, String supplierName) {
        return supplierService.supplierList(page, rows, supplierName);
    }


    /**
     * 保存供应商信息
     * @param supplier 供应商信息
     * @return ServiceVO<Object>
     */
    @PostMapping("/save")
    public ServiceVO<Object> saveOrUpdate(Supplier supplier) {
        return supplierService.saveOrUpdate(supplier);
    }

    /**
     * 删除供应商信息(支持批量删除)
     * @param ids 供应商id串
     * @return ServiceVO<Object>
     */
    @PostMapping("/delete")
    public ServiceVO<Object> deleteById(String ids) {
        return supplierService.deleteById(ids);
    }

}
